package com.carmes.controller;

import com.carmes.dao.CustomercomplaintMapper;
import com.carmes.entity.Processquality;
import com.carmes.service.ProcessqualityService;
import com.carmes.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 过程质量控制层
 */
@Controller
@RequestMapping("/api/processquality")
public class ProcessqualityController {


    @Autowired
    private ProcessqualityService service;

    @Autowired
    private CustomercomplaintMapper customercomplaintMapper;

    /**
     * 获取表格统计
     * @return
     */
    @RequestMapping("/getTableCount")
    @ResponseBody
    public Result getTableCount(){
        Map map=new HashMap();
        List<Integer> processqualities=this.service.getTableCount();
        map.put("processqualities",processqualities);
        List<Integer> customercomplaint=this.customercomplaintMapper.getTableCount();
        map.put("customercomplaint",customercomplaint);
        return Result.reOk("查询成功",map);
    }

    /**
     * 获取饼状图统计
     * @return
     */
    @RequestMapping("/getChartCount")
    @ResponseBody
    public Result getChartCount(){
        Map map=new HashMap();
        List<Integer> processqualitiesChart=this.service.getChartCount();
        map.put("processqualitiesChart",processqualitiesChart);
        List<Integer> customercomplaintChart=this.customercomplaintMapper.getChartCount();
        map.put("customercomplaintChart",customercomplaintChart);
        return Result.reOk("查询成功",map);
    }

}
